Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
how to get user_name from the title that has "eJx2" in it from this json array?

I wanna get user_name from one of these that have "eJx2" in it. I have this code but this code prints all of "user_name"s. I want to just get the user_name of those that have "eJx2" in it.

var titles = arry.data.map(el => el.title);
for (var k in titles) {
    var never = titles[k].includes('eJx2');
    if (never) {
        var names = arry.data.map(el => el.user_name);
        console.log(names);
    }
}

and this is the json :

   {
  data: [
    {
      id: '46475273517',
      user_name: 'testtwo',
      title: 'Hello this is my test for the eJx2',
      is_set: true
    },
    {
      id: '46471542013',
      user_name: 'testone',
      title: 'Hello this is my test for the eJx3',
      is_set: false
    },
    {
      id: '46474254233',
      user_name: 'testthree',
      title: 'Hello this is my test for the eJx7',
      is_set: false
    }
  ],
  pagination: {
    cursor: 'eyJiIjp7IkN1cnNvciI6ImV5SnpJam80TXpBeExqSTBNemcwTVRnME56WTVOQ3dpWkNJNlptRnNjMlVzSW5RaU9uUnlkV1Y5In0sImEiOnsiQ3Vyc29yIjoiZXlKeklqbzFOREV1T1RnMk56STNNall5TkRReE5Dd2laQ0k2Wm1Gc2MyVXNJblFpT25SeWRXVjkifX0'
  }
}
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Use array filter

array.data.filter(item => item.title.includes("eJx2"))

var array = {
  data: [
    {
      id: '46475273517',
      user_name: 'testtwo',
      title: 'Hello this is my test for the eJx2',
      is_set: true
    },
    {
      id: '46471542013',
      user_name: 'testone',
      title: 'Hello this is my test for the eJx3',
      is_set: false
    },
    {
      id: '46474254233',
      user_name: 'testthree',
      title: 'Hello this is my test for the eJx7',
      is_set: false
    }
  ],
  pagination: {
    cursor: 'eyJiIjp7IkN1cnNvciI6ImV5SnpJam80TXpBeExqSTBNemcwTVRnME56WTVOQ3dpWkNJNlptRnNjMlVzSW5RaU9uUnlkV1Y5In0sImEiOnsiQ3Vyc29yIjoiZXlKeklqbzFOREV1T1RnMk56STNNall5TkRReE5Dd2laQ0k2Wm1Gc2MyVXNJblFpT25SeWRXVjkifX0'
  }
}

var filteredData = array.data.filter(item => item.title.includes("eJx2"))

console.log(filteredData)

about 4 years ago · Juan Pablo Isaza Denunciar

0

Use filter() to filter title have 'eJx2' and map() to get only user_name:

 const arry = {
  data: [
    {
      id: '46475273517',
      user_name: 'testtwo',
      title: 'Hello this is my test for the eJx2',
      is_set: true
    },
    {
      id: '46471542013',
      user_name: 'testone',
      title: 'Hello this is my test for the eJx3',
      is_set: false
    },
    {
      id: '46474254233',
      user_name: 'testthree',
      title: 'Hello this is my test for the eJx7',
      is_set: false
    }
  ],
  pagination: {
    cursor: 'eyJiIjp7IkN1cnNvciI6ImV5SnpJam80TXpBeExqSTBNemcwTVRnME56WTVOQ3dpWkNJNlptRnNjMlVzSW5RaU9uUnlkV1Y5In0sImEiOnsiQ3Vyc29yIjoiZXlKeklqbzFOREV1T1RnMk56STNNall5TkRReE5Dd2laQ0k2Wm1Gc2MyVXNJblFpT25SeWRXVjkifX0'
  }
}

const result = arry.data.filter(({title}) => title.includes("eJx2")).map(el => el.user_name)
console.log(result)

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda